Skip to content

feat: protobuf schema registry, typed storage, and persistence - #84

Merged
kacy merged 8 commits into
mainfrom
feat/protobuf-storage
Feb 10, 2026
Merged

feat: protobuf schema registry, typed storage, and persistence#84
kacy merged 8 commits into
mainfrom
feat/protobuf-storage

Conversation

@kacy

@kacy kacy commented Feb 10, 2026

Copy link
Copy Markdown
Owner

summary

adds native protobuf value storage behind a protobuf feature flag. this is PR 1 of 3 — the foundation layer that includes the schema registry, Value::Proto type, and full persistence support (AOF + snapshot + recovery). command parsing and server wiring come in PR 2.

key additions:

  • schema registry (crates/ember-core/src/schema.rs) — stores compiled FileDescriptorSet descriptors using prost-reflect, validates protobuf values at write time, supports registration, validation, describe, and restore (for recovery)
  • Value::Proto variant — new value type carrying type_name + data (Bytes), with memory tracking
  • keyspace methodsproto_set, proto_get, proto_type following existing SET/GET patterns
  • shard dispatchProtoSet, ProtoGet, ProtoType request/response variants with dispatch arms
  • AOF persistenceTAG_PROTO_SET (23) and TAG_PROTO_REGISTER (24) record types with serialization/deserialization
  • snapshot persistenceTYPE_PROTO (5) snap value type with read/write support
  • recoveryRecoveredValue::Proto variant, AOF replay for proto records
  • engine wiringschema_registry field on EngineConfig and Engine with accessor

the entire feature is gated behind #[cfg(feature = "protobuf")] — compiles cleanly with and without the flag.

what was tested

  • cargo test -p emberkv-core --features protobuf — 310 tests pass (9 new schema registry tests)
  • cargo test -p emberkv-core — 301 tests pass (no regressions without feature)
  • cargo test -p ember-persistence --features protobuf — 66 tests pass
  • cargo build -p ember-server --features protobuf — builds clean
  • cargo build -p ember-server — builds clean without feature

design considerations

  • validation at server layer, not keyspace — the keyspace is schema-unaware. validation happens before routing to shards, keeping the hot path simple. the schema registry is Arc<RwLock<SchemaRegistry>> shared across connections.
  • prost-reflect for dynamic messages — no codegen required. users supply pre-compiled FileDescriptorSet bytes from protoc --descriptor_set_out.
  • feature cascadingember-server/protobuf enables emberkv-core/protobuf which enables ember-persistence/protobuf, keeping dependency management clean.
  • restore vs registerrestore() is idempotent (skips duplicates silently) for safe AOF replay. register() returns an error on duplicates for user-facing commands.

kacy added 8 commits February 10, 2026 11:24
adds the `protobuf` feature gate across the workspace. when enabled,
ember-core gains prost-reflect for dynamic protobuf message handling.
the feature cascades: ember-server/protobuf enables
emberkv-core/protobuf and ember-persistence/protobuf.
SchemaRegistry stores compiled FileDescriptorSet descriptors and
validates protobuf values at write time. supports registration,
validation, introspection (describe/list), and recovery (restore).
gated behind the `protobuf` feature flag.
adds a new Proto { type_name, data } variant to the Value enum, gated
behind the protobuf feature. updates PartialEq, type_name(), value_size(),
is_large_value(), and snapshot/recovery code to handle the new type.
type-checked read/write operations for protobuf values. no schema
validation at this layer — that's the server's job. follows the same
memory enforcement and expiry patterns as existing set/get.
adds ProtoSet/ProtoGet/ProtoType to ShardRequest/ShardResponse with
dispatch arms calling the keyspace methods. AOF records ProtoSet and
ProtoRegister handle persistence and recovery. also fills in missing
read_payload_for_tag arms for tags 14-22 (HSET, HDEL, etc).
adds optional SharedSchemaRegistry to EngineConfig and Engine,
with an accessor method for the server layer. implements Debug
for SchemaRegistry manually since DescriptorPool doesn't derive it.
@kacy
kacy merged commit 35744cc into main Feb 10, 2026
7 checks passed
@kacy
kacy deleted the feat/protobuf-storage branch February 10, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant